<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>条件与循环</h2>
      <!-- v-if指令用于做条件的判断 -->
      <!-- 变量或者表达式的值如果为真，这个标签就渲染，否则就不渲染 -->
      <p v-if="show === 2">太难了</p>
      <p v-if="show2">太难了2</p>
      <button v-on:click="show2 = !show2">btn</button>

      <hr />

      <!-- v-for的指令是用于做循环渲染 -->
      <!-- v-for是哪个元素要多次渲染就给哪个元素加 -->
      <ul>
        <li v-for="value in todos">{{ value.text }}</li>
      </ul>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          show: 3,
          show2: true,

          todos: [
            { text: "学习 JavaScript" },
            { text: "学习 Vue" },
            { text: "整个牛项目" },
          ],
        },
      });
    </script>
  </body>
</html>
